package com.example.webdriveddd.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.Getter;

@Embeddable
public class ShareInfo {
    @Column(name = "password")
    private String password;
    @Getter
    @Column(name = "enabled")
    private boolean enabled;
    public static ShareInfo disable(){
        ShareInfo shareInfo = new ShareInfo();
        shareInfo.enabled=false;
        shareInfo.password="";
        return shareInfo;
    }
    public static ShareInfo enable(String password){
        ShareInfo shareInfo = new ShareInfo();
        shareInfo.enabled=true;
        if (password.isEmpty()){
            throw new IllegalArgumentException("Password cannot be empty");
        }
        shareInfo.password=password;
        return shareInfo;
    }
    public boolean verifyPassword(String password){
        return this.password.equals(password);
    }
}
